home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / nihcl-30.lha / nihcl-3.0 / lib / OrderedCltn.h < prev    next >
C/C++ Source or Header  |  1990-05-19  |  3KB  |  92 lines

  1. #ifndef    ORDEREDCLTN_H
  2. #define    ORDEREDCLTN_H
  3.  
  4. /*$Header: /afs/alw.nih.gov/unix/sun4_40c/usr/local/src/nihcl-3.0/share/lib/RCS/OrderedCltn.h,v 3.0 90/05/20 00:20:44 kgorlen Rel $*/
  5.  
  6. /* OrderedCltn.h -- declarations for abstract ordered collections
  7.  
  8.     THIS SOFTWARE FITS THE DESCRIPTION IN THE U.S. COPYRIGHT ACT OF A
  9.     "UNITED STATES GOVERNMENT WORK".  IT WAS WRITTEN AS A PART OF THE
  10.     AUTHOR'S OFFICIAL DUTIES AS A GOVERNMENT EMPLOYEE.  THIS MEANS IT
  11.     CANNOT BE COPYRIGHTED.  THIS SOFTWARE IS FREELY AVAILABLE TO THE
  12.     PUBLIC FOR USE WITHOUT A COPYRIGHT NOTICE, AND THERE ARE NO
  13.     RESTRICTIONS ON ITS USE, NOW OR SUBSEQUENTLY.
  14.  
  15. Author:
  16.     K. E. Gorlen
  17.     Computer Systems Laboratory, DCRT
  18.     National Institutes of Health
  19.     Bethesda, MD 20892
  20.  
  21. $Log:    OrderedCltn.h,v $
  22.  * Revision 3.0  90/05/20  00:20:44  kgorlen
  23.  * Release for 1st edition.
  24.  * 
  25. */
  26.  
  27. #include "SeqCltn.h"
  28. #include "ArrayOb.h"
  29.  
  30. class OrderedCltn: public SeqCltn {
  31.     DECLARE_MEMBERS(OrderedCltn);
  32.     void errEmpty(const char* fn) const;
  33.     void errNotFound(const char* fn, const Object& ob) const;
  34. protected:
  35.     int endIndex;
  36.     ArrayOb contents;
  37.     Object* addAtIndex(int i, Object& ob);
  38.     Object* removeAtIndex(int i);
  39. protected:        // storer() functions for object I/O
  40.     virtual void storer(OIOofd&) const;
  41.     virtual void storer(OIOout&) const;
  42. public:
  43.     OrderedCltn(unsigned size =DEFAULT_CAPACITY);
  44. #ifndef BUG_TOOBIG
  45. // yacc stack overflow
  46.     OrderedCltn(const OrderedCltn&);
  47. #endif
  48.     bool operator!=(const OrderedCltn& a) const { return !(*this==a); }
  49.     void operator=(const OrderedCltn&);
  50.     bool operator==(const OrderedCltn&) const;
  51.     Object*& operator[](int i) {
  52.         if ((unsigned)i >= endIndex) indexRangeErr();
  53.         return contents[i];
  54.     }
  55.     const Object *const& operator[](int i) const {
  56.         if ((unsigned)i >= endIndex) indexRangeErr();
  57.         return contents[i];
  58.     }
  59.     OrderedCltn operator&(const SeqCltn& cltn) const;    // concatenation operator 
  60.     void operator&=(const SeqCltn& cltn);
  61.     virtual Object* add(Object&);
  62.     virtual Object* addAfter(const Object& ob, Object& newob);
  63.     virtual Object* addAllLast(const OrderedCltn&);
  64.     virtual Object* addBefore(const Object& ob, Object& newob);
  65.     virtual Collection& addContentsTo(Collection& cltn) const;
  66.     virtual Object* addLast(Object& ob);
  67.     virtual Object* after(const Object&) const;
  68.     virtual Object*& at(int i);
  69.     virtual const Object *const& at(int i) const;
  70.     virtual void atAllPut(Object& ob);
  71.     virtual Object* before(const Object&) const;
  72.     virtual unsigned capacity() const;
  73.     virtual void deepenShallowCopy();
  74.     virtual Object* first() const;
  75.     virtual unsigned hash() const;
  76.      virtual int indexOf(const Object& ob) const;
  77.     virtual int indexOfSubCollection(const SeqCltn& cltn, int start=0) const;
  78.     virtual bool isEmpty() const;
  79.     virtual Object* last() const;
  80.     virtual unsigned occurrencesOf(const Object&) const;
  81.     virtual Object* remove(const Object&);
  82.     virtual void removeAll();
  83.     virtual Object* removeId(const Object&);
  84.     virtual Object* removeLast();
  85.     virtual void replaceFrom(int start, int stop, const SeqCltn& replacement, int startAt =0);
  86.     virtual void reSize(unsigned newSize);
  87.     virtual unsigned size() const;
  88.     virtual void sort();
  89. };
  90.  
  91. #endif
  92.